// C_Socket.h: interface for the C_Socket class.
//
//////////////////////////////////////////////////////////////////////

#ifndef _C_SOCKET_H_
#define _C_SOCKET_H_
#include <stdio.h>

#include <winsock.h>

#define MAX_CLIENT_NUM  100

#define socklen_t int  

class C_Socket
{
 public:
  // Constructor
  C_Socket();
  virtual ~C_Socket();

 
  int Open(int iDomain, int iType, int iProtocol = 0);
  int Close();

  
  int GetDomain();
  
  
  void SetOption(int iLevel, int iOption, const char* pOptVal, socklen_t iOptLen);
  void GetOption(int iLevel, int iOption, char* pOptVal, socklen_t* pOptLen);

  
  int Bind(char* pcaddr, char*pcport);
  int Connect(char* strPeer, char* strPort);

  // Server
  int Listen(int iBackLog);
  unsigned int  Accept(char* pcClientIP,char* pcClientPort);

  // Send / Receive on this socket without timeout
  int Send(SOCKET m_SendSocket,char* pBuff, int iBuffLen, int iFlags ); 
  int Recv(SOCKET m_ClientSocket,char* pBuff,int iBuffLen,int iFlags);

  int Sendto(char* pcPeerAddr,char* pcPeerPort,char* pBuff, int iBuffLen, int iFlags);
  int Recvfrom(char* pcPeerAddr,char* pcPeerPort,char* pBuff, int iBuffLen, int iFlags);

 

 

  // Get informations on the connection
  char*  GetLocalName();
  char*  GetLocalPort();
  char*  GetPeerName();
  char*  GetPeerPort();
  
	

 private:
  // Private data



  int m_iDomain;
  int m_iType;

  SOCKET m_hSocket;

};

#endif 